package com.kungkhies.mvc.rest.kungkher;

import java.util.List;

import javax.inject.Inject;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kungkhies.domain.kungkher.Kungkher;
import com.kungkhies.domain.kungkhie.KungkhieSummary;
import com.kungkhies.services.kungkher.KungkherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
@RequestMapping("/kungkhers")
public class KungkhersController
{
    private KungkherService kungkherService;

    @Autowired
    public KungkhersController(KungkherService kungkherService)
    {
        this.kungkherService = kungkherService;
    }

    @RequestMapping(value = "/{kungkherName}/kungkhies",
    method = RequestMethod.GET)
    public @ResponseBody
    List<KungkhieSummary> kungkhiesForKungkher(
            @PathVariable("kungkherName") String kungkherName)
    {
        Kungkher kungkher = kungkherService.getKungkher(kungkherName);
        return kungkherService.getKungkhiesForKungkher(kungkher);
    }
}
